<?php
class ConnectionName_Controller extends Base_Controller {

	/**
	 * Manipula o xml utilizado para descrever a tela
	 * Handles the xml used to describe the interface
	 * @var GladeXML
	 */
	private $objGlade;
	
	/**
	 * Objeto janela recuperado do XML do Glade
	 * Window object recovered from Glade XML
	 * @var GtkWindow
	 */
	private $objWindow;
	
	private $strConnectionName;
	
	private $intExitCode;

	/**
	 * Conecta os sinais e define o titulo da janela
	 * Connect the signals and defines the title of the window
	 */
	public function __construct(GtkWindow $objWindowParent) {
		$this->objGlade = new GladeXML(dirname(__FILE__) . '/resources/xml/connectionName.glade');
		$this->objGlade->signal_autoconnect_instance($this);
		$this->objWindow = $this->objGlade->get_widget('dialogConnectionName');
		$this->objWindow->set_title(ts::config('title.main'));
		$this->objWindow->set_parent_window($objWindowParent->window);

		$this->intExitCode = 2;
		$this->objWindow->run();
	}

	public function btnOK_connectionName_clicked() {
		$txtConnectionName = $this->objGlade->get_widget('txtName');
		$this->strConnectionName = $txtConnectionName->get_text();
		$this->intExitCode = 0;
		$this->objWindow->destroy();
	}
	
	public function getConnectionName() {
		return $this->strConnectionName;
	}
	
	public function getExitCode() {
		return $this->intExitCode;
	}
	
	public function btnCancel_connectionName_clicked() {
		$this->intExitCode = 1;
		$this->objWindow->destroy();
	}
	
	public function txtName_icon_press() {
		$txtConnectionName = $this->objGlade->get_widget('txtName');
		$txtConnectionName->set_text('');
	}
}
?>